﻿<!--#include file="conn.asp"-->
<!--#include file="inc/CHAR.INC"-->
<%if request("act")="del" then
conn.execute("delete from ad where id in("&request("id")&")")
conn.close
set conn=nothing
response.redirect Request.ServerVariables("HTTP_REFERER")
response.end
end if%>
<%if request("act")="join" then
adtitle=request.form("adtitle")
adcontent=request.form("adcontent")
adfilename=request.form("adfilename")
if adtitle ="" then
response.write("<script>alert('错误：标题不能为空!');history.go(-1)</script>")
response.end
end if
if adcontent ="" then
response.write("<script>alert('错误：文件名不能为空!');history.go(-1)</script>")
response.end
end if
if adcontent ="" then
response.write("<script>alert('错误：内容不能为空!');history.go(-1)</script>")
response.end
end if

set rs=server.createobject("adodb.recordset")
sql="select * from ad"
rs.open sql,conn,1,3
rs.AddNew
rs("adtitle")=adtitle
rs("adcontent")=adcontent
rs("adfilename")=adfilename
rs.Update
rs.Close
response.write("<script>alert('成功：添加广告成功!');location='ad_manage.asp'</script>")
response.end
%>
<%end if%>
<%if request("act")="mdok" then
id=request.form("id")
adtitle=request.form("adtitle")
adcontent=request.form("adcontent")
adfilename=request.form("adfilename")
if adtitle ="" then
response.write("<script>alert('错误：标题不能为空!');history.go(-1)</script>")
response.end
end if
if adcontent ="" then
response.write("<script>alert('错误：文件名不能为空!');history.go(-1)</script>")
response.end
end if
if adcontent ="" then
response.write("<script>alert('错误：内容不能为空!');history.go(-1)</script>")
response.end
end if
set rs=server.createobject("adodb.recordset")
sql="select * from ad where id="&id
rs.open sql,conn,1,3
rs("adtitle")=adtitle
rs("adcontent")=adcontent
rs("adfilename")=adfilename
rs.Update
rs.Close
set rs=nothing 
response.write("<script>alert('成功：修改广告成功!');location='ad_manage.asp'</script>")
response.end
end if%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
    <title></title>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    <link href="images/style.css" type="text/css" rel="stylesheet">
    <meta content="MSHTML 6.00.3790.0" name="GENERATOR">
    <style type="text/css">
<!--
.STYLE2 {
	color: #000000;
	font-weight: bold;
}
-->
</style>
</head>
<body style="font-size: 12px; v-text-align: center" leftmargin="0" topmargin="3"
    align="center" marginheight="0" marginwidth="0">
    <%if request("act")="modify" then
set rs=server.CreateObject("ADODB.RecordSet")
sql="select * from ad where id = "&request("id")&""
rs.Open sql,conn,1,1
if rs.EOF then
response.write("<script>alert('错误：本新闻不存在或是已经删除!');history.go(-1)</script>")
response.end
else
id=rs("id")
adtitle=rs("adtitle")
adcontent=rs("adcontent")
adfilename=rs("adfilename")
end if 
    %><form name="form1" method="post" action="?act=mdok">
    <table width="98%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC"
        style='margin-bottom: 5px'>
        <tr>
            <td colspan="3" bgcolor="e1e1e1">
                <div align="center" class="STYLE2">
                    修改广告</div>
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td width="16%">
                <div align="right">
                    广告名称：</div>
            </td>
            <td width="48%">
                <input name="adtitle" type="text" id="adtitle" value="<%=adtitle%>" size="30">
                <input name="id" type="hidden" value="<%=id%>">
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td>
                <div align="right">
                    广告文件名：</div>
            </td>
            <td>
                <input type="text" name="adfilename" value="<%=adfilename%>" size="30">
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td>
                <div align="right">
                    广告代码：</div>
            </td>
            <td colspan="2">
                <textarea name="adcontent" cols="60" rows="10" id="adcontent"><%=adcontent%></textarea>
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td colspan="3">
                <div align="center">
                    &nbsp;
                    <input name="goback3" type="button" class="Submit" id="goback33" onclick="history.back();"
                        value="返回">
                    &nbsp;
                    <input type="submit" name="Submit2" class="Submit" value="修改资料" onclick="{if(confirm('确定资料？')){return true;}return false;}">
                </div>
            </td>
        </tr>
    </table>
    </form>
    <%end if%>
    <%if request("act")="add" then
    %><form name="form1" method="post" action="?act=join">
    <table width="98%" border="0" align="center" cellpadding="5" cellspacing="1" bgcolor="#CCCCCC"
        style='margin-bottom: 5px'>
        <tr>
            <td colspan="3" bgcolor="e1e1e1">
                <div align="center" class="STYLE2">
                    增加广告</div>
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td width="16%">
                <div align="right">
                    广告名称：</div>
            </td>
            <td width="48%">
                <input name="adtitle" type="text" id="adtitle" size="30">
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td width="16%">
                <div align="right">
                    广告文件名：</div>
            </td>
            <td width="48%">
                <input name="adfilename" type="text" id="adfilename" size="30">
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td>
                <div align="right">
                    广告代码：</div>
            </td>
            <td colspan="2">
                <textarea name="adcontent" cols="60" rows="10" id="adcontent"></textarea>
            </td>
        </tr>
        <tr bgcolor="#FFFFFF">
            <td colspan="3">
                <div align="center">
                    <input type="submit" name="Submit" class="Submit" value="增加广告">
                </div>
            </td>
        </tr>
    </table>
    </form>
    <%end if%>
    <div align="center">
    </div>
</body>
</html>
